/*****************************************************************************/
function OWTransactionState(space,id)
{
	this.space=space;
	this.state_id=id;
	if (this.state_id) this.load();
}

/*****************************************************************************/
OWTransactionState.protostate.load=function() {
	var a=space.site.sql.execute_and_fetch_one("transaction_states/get",this);
	for (k in a) this[k]=a[k];
}

/*****************************************************************************/
OWTransactionState.protostate.save=function() {
	if (this.state_id) {
		space.site.sql.execute("transaction_states/update",this);
	} else {
		space.site.sql.execute("transaction_states/insert",this);
		this.state_id=space.site.sql.execute_and_fetch_one("transaction_states/max_id")['id'];
	}
}

/*****************************************************************************/
OWTransactionState.protostate.remove=function() {
	space.site.sql.execute("transaction_states/delete",this);
}

/*****************************************************************************/
function OWTransactionType(space,id)
{
	this.space=space;
	this.type_id=id;
	if (this.type_id) this.load();
}

/*****************************************************************************/
OWTransactionType.prototype.load=function() {
	var a=space.site.sql.execute_and_fetch_one("transaction_types/get",this);
	for (k in a) this[k]=a[k];
	states=
}

/*****************************************************************************/
OWTransactionType.prototype.save=function() {
	if (this.type_id) {
		space.site.sql.execute("transaction_types/update",this);
	} else {
		space.site.sql.execute("transaction_types/insert",this);
		this.type_id=space.site.sql.execute_and_fetch_one("transaction_types/max_id")['id'];
	}
}

/*****************************************************************************/
OWTransactionType.prototype.remove=function() {
	space.site.sql.execute("transaction_types/delete",this);
}


/*****************************************************************************/
exports.models={
	TransactionType: function(space,id) {return OWTransactionType(space,id);},
	Transaction: function(space,id) {return OWTransaction(space,id);}
};

/*****************************************************************************/

